<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script src="https://cdn.staticfile.org/react/16.4.0/umd/react.development.js"></script>
<script src="https://cdn.staticfile.org/react-dom/16.4.0/umd/react-dom.development.js"></script>
<!-- 生产环境中不建议使用 -->
<script src="https://cdn.staticfile.org/babel-standalone/6.26.0/babel.min.js"></script>
<script src="https://cdn.bootcss.com/prop-types/15.6.1/prop-types.js"></script>

<div id="test1"></div>
<div id="test2"></div>
<div id="test3"></div>

<script type="text/babel">
    //类式组件

    class Person extends React.Component {

        render() {
            return (
                <ul>
                    <li>姓名：{this.props.name}</li>
                    <li>性别：{this.props.sex}</li>
                    <li>年龄：{this.props.age +1}</li>
                </ul>
            )
        }
    }

    //对类型的必要性 性质
    Person.propTypes ={
        name:PropTypes.string.isRequired,
        sex:PropTypes.string,
        age:PropTypes.number,
        //func-限制为函数类型
        speck:PropTypes.func
    }

    Person.defaultProps = {
        sex:'男',
        age:18
    }

    function speck(){
        console.log("我说话了")
    }

    const tomInfo = {name: "tom"}

    console.log('@',{...tomInfo})

    ReactDOM.render(<Person {...tomInfo} speck={speck}/>, document.getElementById("test1"))
    ReactDOM.render(<Person name="jerry" age={20} sex="女"/>, document.getElementById("test2"))
    ReactDOM.render(<Person name="mikey" age={30} sex="男"/>, document.getElementById("test3"))
</script>
</body>
</html>